
#include"VSphere.h"
#include<stdlib.h>
#include<math.h>
#include<stdio.h>


void VSphere::FillCoordAndBox ()
{
  float * v_normals = GetNormalArray();
  float * vertices = GetVertArray();
  free(v_normals);
  SetNormalArray(vertices);
  //printf("VSphere %d %d\n", n_vertices,n_triangles);
  float theta_step = 2*_PI/(n-1);
  float phi_step = _PI/(n-1);
  float theta_mult=0;
  float phi_mult=-1;
  float theta = 0;
  float phi = 0;
  for(int i=0; i<n_vertices; i++){
    if(i%n==0){
      theta_mult=0;
      phi_mult++;
    }
    theta = theta_mult*theta_step;
    phi = phi_mult*phi_step;
    vertices[i*3]   = sin(phi)*cos(theta);
    vertices[i*3+1] = sin(phi)*sin(theta);
    vertices[i*3+2] = cos(phi);
    theta_mult++;
  }
  //CalcNormals();
  xmax=1.0;
  ymax=1.0;
  zmax=1.0;
  xmin=-1.0;
  ymin=-1.0;
  zmin=-1.0;
}
